bitkeeper revision 1.304.1.7 (3f0bf195LrxhtbvmW2HyL5qXkoR63g)
authorrac61@labyrinth.cl.cam.ac.uk <rac61@labyrinth.cl.cam.ac.uk>
Wed, 9 Jul 2003 10:42:29 +0000 (10:42 +0000)
committerrac61@labyrinth.cl.cam.ac.uk <rac61@labyrinth.cl.cam.ac.uk>
Wed, 9 Jul 2003 10:42:29 +0000 (10:42 +0000)
Undo silly design decision by me; namely, to do any checking of values in the Parse classes.
Instead, it should be done in the Command classes, so that the web interface need not duplicate code.

16 files changed:
tools/control/src/org/xenoserver/cmdline/ParsePartitionsAdd.java
tools/control/src/org/xenoserver/cmdline/ParsePhysicalGrant.java
tools/control/src/org/xenoserver/cmdline/ParsePhysicalRevoke.java
tools/control/src/org/xenoserver/cmdline/ParseVbdCreate.java
tools/control/src/org/xenoserver/cmdline/ParseVdCreate.java
tools/control/src/org/xenoserver/cmdline/ParseVdDelete.java
tools/control/src/org/xenoserver/control/CommandPartitionAdd.java
tools/control/src/org/xenoserver/control/CommandPhysicalGrant.java
tools/control/src/org/xenoserver/control/CommandPhysicalRevoke.java
tools/control/src/org/xenoserver/control/CommandVbdCreate.java
tools/control/src/org/xenoserver/control/CommandVbdCreatePhysical.java
tools/control/src/org/xenoserver/control/CommandVdCreate.java
tools/control/src/org/xenoserver/control/CommandVdDelete.java
tools/control/src/org/xenoserver/control/Partition.java
tools/control/src/org/xenoserver/control/VirtualDisk.java
tools/control/src/org/xenoserver/control/VirtualDiskManager.java

index 041e222b4fc2543a8c0561151d84c9ccd9ec9c27..4076bcf51fe0e22a78d8d5d2f9ac2fbc6aa406bc 100644 (file)
@@ -6,55 +6,38 @@ import org.xenoserver.control.CommandFailedException;
 import org.xenoserver.control.CommandPartitionAdd;
 import org.xenoserver.control.Defaults;
 import org.xenoserver.control.Library;
-import org.xenoserver.control.Partition;
-import org.xenoserver.control.PartitionManager;
-import org.xenoserver.control.Settings;
 
 public class ParsePartitionsAdd extends CommandParser {
-  public void parse(Defaults d, LinkedList args) throws ParseFailedException, CommandFailedException {
-    boolean force = getFlagParameter(args, 'f');
-    String partition_name = getStringParameter(args, 'p', "");
-    String size = getStringParameter(args, 'c', "128M");
-    
-    if (partition_name.equals("")) {
-      throw new ParseFailedException("Expected -p<partition_name>");
-    }
-      
-    long chunksize = Library.parseSize( size ) / Settings.SECTOR_SIZE;
-    if ( chunksize <= 0 ) {
-      throw new CommandFailedException("Chunk size " + size + " is smaller than sector size.");
-    }
-    
-    // Initialise the partition manager and look up the partition
-    loadState();
-    Partition p = PartitionManager.IT.getPartition(partition_name);
-    
-    if ( p == null ) {
-      throw new CommandFailedException("Partition " + partition_name + " does not exist.");
-    }
-    
-    // Check if this partition belongs to the VDM
-    if (p.isXeno() && !force) {
-      throw new CommandFailedException("Refusing to add partition as it is already allocated to the virtual disk manager. Use -f if you are sure.");
-    }
-    
-    String output = new CommandPartitionAdd( p, chunksize ).execute();
-    if ( output != null ) {
-      System.out.println( output );
+    public void parse(Defaults d, LinkedList args)
+        throws ParseFailedException, CommandFailedException {
+        boolean force = getFlagParameter(args, 'f');
+        String partition_name = getStringParameter(args, 'p', "");
+        String size = getStringParameter(args, 'c', "128M");
+
+        if (partition_name.equals("")) {
+            throw new ParseFailedException("Expected -p<partition_name>");
+        }
+
+        loadState();
+        String output =
+            new CommandPartitionAdd(partition_name, Library.parseSize(size),force)
+                .execute();
+        if (output != null) {
+            System.out.println(output);
+        }
+        saveState();
     }
-    saveState();
-  }
 
-  public String getName() {
-    return "add";
-  }
+    public String getName() {
+        return "add";
+    }
 
-  public String getUsage() {
-    return "-p<partition_name> [-f] [-c<chunk_size>]";
-  }
+    public String getUsage() {
+        return "-p<partition_name> [-f] [-c<chunk_size>]";
+    }
 
-  public String getHelpText() {
-    return "Add the specified partition to the virtual disk manager's free\n" +
-           "space. -c changes the default chunk size. -f forces add.";
-  }
+    public String getHelpText() {
+        return "Add the specified partition to the virtual disk manager's free\n"
+            + "space. -c changes the default chunk size. -f forces add.";
+    }
 }
index 60cb925dd1b35a83d2d09b853a5152496c98b692..f332d5c698b7931d7c7299b72da0b326f34f2bb9 100644 (file)
@@ -6,60 +6,50 @@ import org.xenoserver.control.CommandFailedException;
 import org.xenoserver.control.CommandPhysicalGrant;
 import org.xenoserver.control.Defaults;
 import org.xenoserver.control.Mode;
-import org.xenoserver.control.Partition;
-import org.xenoserver.control.PartitionManager;
 
 public class ParsePhysicalGrant extends CommandParser {
-  public void parse(Defaults d, LinkedList args) throws ParseFailedException, CommandFailedException {
-    int domain_id = getIntParameter(args, 'n', 0);
-    boolean force = getFlagParameter(args, 'f');
-    String partition_name = getStringParameter(args, 'p', "");
-    boolean write = getFlagParameter(args, 'w');
-    
-    if (domain_id == 0) {
-      throw new ParseFailedException("Expected -n<domain_id>");
-    }
-    if (partition_name.equals("")) {
-      throw new ParseFailedException("Expected -p<partition_name>");
-    }
-      
-    Mode mode;
-    if (write) {
-      mode = Mode.READ_WRITE;
-    } else {
-      mode = Mode.READ_ONLY;
-    }
-      
-    // Initialise the partition manager and look up the partition
-    loadState();
-    Partition p = PartitionManager.IT.getPartition(partition_name);
-    
-    if ( p == null ) {
-      throw new CommandFailedException("Partition " + partition_name + " does not exist.");
-    }
-    
-    // Check if this partition belongs to the VDM
-    if (p.isXeno() && !force) {
-      throw new CommandFailedException("Refusing to grant physical access as the given partition is allocated to the virtual disk manager. Use -f if you are sure.");
-    }
-         
-    String output = new CommandPhysicalGrant( d, domain_id, p, mode ).execute();
-    if ( output != null ) {
-      System.out.println( output );
+    public void parse(Defaults d, LinkedList args)
+        throws ParseFailedException, CommandFailedException {
+        int domain_id = getIntParameter(args, 'n', 0);
+        boolean force = getFlagParameter(args, 'f');
+        String partition_name = getStringParameter(args, 'p', "");
+        boolean write = getFlagParameter(args, 'w');
+
+        if (domain_id == 0) {
+            throw new ParseFailedException("Expected -n<domain_id>");
+        }
+        if (partition_name.equals("")) {
+            throw new ParseFailedException("Expected -p<partition_name>");
+        }
+
+        Mode mode;
+        if (write) {
+            mode = Mode.READ_WRITE;
+        } else {
+            mode = Mode.READ_ONLY;
+        }
+
+        // Initialise the partition manager and look up the partition
+        loadState();
+        String output =
+            new CommandPhysicalGrant(d, domain_id, partition_name, mode, force)
+                .execute();
+        if (output != null) {
+            System.out.println(output);
+        }
     }
-  }
 
-  public String getName() {
-    return "grant";
-  }
+    public String getName() {
+        return "grant";
+    }
 
-  public String getUsage() {
-    return "-n<domain_id> -p<partition_name> [-f] [-w]";
-  }
+    public String getUsage() {
+        return "-n<domain_id> -p<partition_name> [-f] [-w]";
+    }
 
-  public String getHelpText() {
-    return "Grant the specified domain access to the given partition.  -w grants" +
-           " read-write instead of read-only.  -f forcibly grants access.";
-  }
+    public String getHelpText() {
+        return "Grant the specified domain access to the given partition.  -w grants"
+            + " read-write instead of read-only.  -f forcibly grants access.";
+    }
 
 }
index 1f075b470865315449d32186ce58c4024556d870..56d37e6dace2d603854cbdfe7f228b644bf0fb15 100644 (file)
@@ -5,8 +5,6 @@ import java.util.LinkedList;
 import org.xenoserver.control.CommandFailedException;
 import org.xenoserver.control.CommandPhysicalRevoke;
 import org.xenoserver.control.Defaults;
-import org.xenoserver.control.Partition;
-import org.xenoserver.control.PartitionManager;
 
 public class ParsePhysicalRevoke extends CommandParser {
     public void parse(Defaults d, LinkedList args)
@@ -23,14 +21,7 @@ public class ParsePhysicalRevoke extends CommandParser {
 
         // Initialise the partition manager and look up the partition
         loadState();
-        Partition p = PartitionManager.IT.getPartition(partition_name);
-
-        if (p == null) {
-            throw new CommandFailedException(
-                "Partition " + partition_name + " does not exist.");
-        }
-
-        String output = new CommandPhysicalRevoke(d, domain_id, p).execute();
+        String output = new CommandPhysicalRevoke(d, domain_id, partition_name).execute();
         if (output != null) {
             System.out.println(output);
         }
index bae98b33e5f02945d48bf200d0994207f95bd2a1..54713b45fc3c6b0dc2b1a9cc238f55958dd18fc4 100644 (file)
@@ -7,10 +7,6 @@ import org.xenoserver.control.CommandVbdCreate;
 import org.xenoserver.control.CommandVbdCreatePhysical;
 import org.xenoserver.control.Defaults;
 import org.xenoserver.control.Mode;
-import org.xenoserver.control.Partition;
-import org.xenoserver.control.PartitionManager;
-import org.xenoserver.control.VirtualDisk;
-import org.xenoserver.control.VirtualDiskManager;
 
 public class ParseVbdCreate extends CommandParser {
     public void parse(Defaults d, LinkedList args)
@@ -41,21 +37,10 @@ public class ParseVbdCreate extends CommandParser {
         loadState();
         String output;
         if (vd_key.equals("")) {
-            Partition p = PartitionManager.IT.getPartition(partition_name);
-            if ( p == null ) {
-                throw new CommandFailedException("No partition " + partition_name + " exists" );
-            }
-            
-            output = new CommandVbdCreatePhysical( p, domain_id, vbd_num, mode ).execute();
+            output = new CommandVbdCreatePhysical( partition_name, domain_id, vbd_num, mode ).execute();
         } else {
-            VirtualDisk vd = VirtualDiskManager.IT.getVirtualDisk(vd_key);
-            if (vd == null) {
-                throw new CommandFailedException(
-                    "No virtual disk with key " + vd_key);
-            }
-
             output =
-                new CommandVbdCreate(vd, domain_id, vbd_num, mode).execute();
+                new CommandVbdCreate(vd_key, domain_id, vbd_num, mode).execute();
         }
         if (output != null) {
             System.out.println(output);
index 3aaeb967acee4cafddf2953adb0f365e1a4394e8..ccacfb3954011fb39ad0383f98f1d1abc2334b7b 100644 (file)
@@ -9,7 +9,6 @@ import org.xenoserver.control.CommandFailedException;
 import org.xenoserver.control.CommandVdCreate;
 import org.xenoserver.control.Defaults;
 import org.xenoserver.control.Library;
-import org.xenoserver.control.Settings;
 
 public class ParseVdCreate extends CommandParser {
     public void parse(Defaults d, LinkedList args)
@@ -39,9 +38,7 @@ public class ParseVdCreate extends CommandParser {
         long size = Library.parseSize(size_s);
 
         loadState();
-        String output =
-            new CommandVdCreate(name, size / Settings.SECTOR_SIZE, expiry)
-                .execute();
+        String output = new CommandVdCreate(name, size, expiry).execute();
         if (output != null) {
             System.out.println(output);
         }
index 6d4f838c4ea746dfdd3503250c71ed9640c0711b..cfbce4a4232ed152ed1e2a816a6c8485a0a5a347 100644 (file)
@@ -5,7 +5,6 @@ import java.util.LinkedList;
 import org.xenoserver.control.CommandFailedException;
 import org.xenoserver.control.CommandVdDelete;
 import org.xenoserver.control.Defaults;
-import org.xenoserver.control.VirtualDiskManager;
 
 public class ParseVdDelete extends CommandParser {
     public void parse(Defaults d, LinkedList args)
@@ -17,11 +16,6 @@ public class ParseVdDelete extends CommandParser {
         }
 
         loadState();
-        if (VirtualDiskManager.IT.getVirtualDisk(vd_key) == null) {
-            throw new CommandFailedException(
-                "Virtual disk " + vd_key + " does not exist");
-        }
-
         String output = new CommandVdDelete(vd_key).execute();
         if (output != null) {
             System.out.println(output);
index 72d1bb631bfca1a443d1818ffa6ec45f88c4ad4a..37db9dff69826e8aadfba4a8bd63986b95db0671 100644 (file)
@@ -4,27 +4,46 @@ package org.xenoserver.control;
  * Add a disk partition to the VirtualDiskManager as a XenoPartition.
  */
 public class CommandPartitionAdd extends Command {
+    /** True to force creation. */
+    private boolean force;
     /** Partition to add as a XenoPartition. */
-    private Partition partition;
-    /** Chunk size to split partition into (in sectors). */
+    private String partition_name;
+    /** Chunk size to split partition into (in bytes). */
     private long chunksize;
 
     /**
      * Constructor for CommandPartitionAdd.
-     * @param partition Partition to add.
-     * @param chunksize Chunk size to split partition into (in sectors).
+     * @param partition_name Partition to add.
+     * @param chunksize Chunk size to split partition into (in bytes).
+     * @param force True to force creation.
      */
-    public CommandPartitionAdd(Partition partition, long chunksize) {
-        this.partition = partition;
+    public CommandPartitionAdd(String partition_name, long chunksize, boolean force) {
+        this.partition_name = partition_name;
         this.chunksize = chunksize;
+        this.force = force;
     }
 
     /**
      * @see org.xenoserver.control.Command#execute()
      */
     public String execute() throws CommandFailedException {
-        VirtualDiskManager.IT.addPartition(partition, chunksize);
-        PartitionManager.IT.addXenoPartition(partition);
-        return "Added partition " + partition.getName();
+        Partition p = PartitionManager.IT.getPartition(partition_name);
+        if (p == null) {
+            throw new CommandFailedException(
+                "Partition " + partition_name + " does not exist.");
+        }
+        // Check if this partition belongs to the VDM
+        if (p.isXeno() && !force) {
+          throw new CommandFailedException("Refusing to add partition as it is already allocated to the virtual disk manager. Use -f if you are sure.");
+        }
+        
+        long size = chunksize / Settings.SECTOR_SIZE;
+        if ( chunksize <= 0 ) {
+          throw new CommandFailedException("Chunk size is smaller than sector size.");
+        }
+    
+        VirtualDiskManager.IT.addPartition(p, size);
+        PartitionManager.IT.addXenoPartition(p);
+        return "Added partition " + p.getName();
     }
 }
index ab56ad65e148da61b44de3e42c829684a65eabbb..0288f32c98fbe490198cc7aa3ff07a09f85c0922 100644 (file)
@@ -9,9 +9,11 @@ public class CommandPhysicalGrant extends Command {
     /** Domain ID to grant access for */ 
     private int domain_id;
     /** Partition to grant access to */
-    private Partition partition;
+    private String partition_name;
     /** Access mode to grant */
     private Mode mode;
+    /** True to force grant */
+    private boolean force;
 
     /**
      * Constructor for CommandPhysicalGrant.
@@ -19,16 +21,19 @@ public class CommandPhysicalGrant extends Command {
      * @param domain_id Domain to grant access for.
      * @param partition Partition to grant access to.
      * @param mode Access mode to grant.
+     * @param force True to force grant
      */
     public CommandPhysicalGrant(
         Defaults d,
         int domain_id,
-        Partition partition,
-        Mode mode) {
+        String partition,
+        Mode mode,
+        boolean force) {
         this.d = d;
         this.domain_id = domain_id;
-        this.partition = partition;
+        this.partition_name = partition;
         this.mode = mode;
+        this.force = force;
     }
 
     /**
@@ -38,6 +43,17 @@ public class CommandPhysicalGrant extends Command {
         Runtime r = Runtime.getRuntime();
         String output = null;
 
+        Partition partition = PartitionManager.IT.getPartition(partition_name);
+    
+        if ( partition == null ) {
+          throw new CommandFailedException("Partition " + partition_name + " does not exist.");
+        }
+    
+        // Check if this partition belongs to the VDM
+        if (partition.isXeno() && !force) {
+          throw new CommandFailedException("Refusing to grant physical access as the given partition is allocated to the virtual disk manager. Use -f if you are sure.");
+        }
+         
         try {
             Process start_p;
             String start_cmdarray[] = new String[7];
index 22473c5beb7d8dbbd1cd90bdaa1fa20fc9b14cfb..71d2efa457c51ac33183795ebbd1a328d77b7a21 100644 (file)
@@ -9,7 +9,7 @@ public class CommandPhysicalRevoke extends Command {
     /** Domain to revoke access from */
     private int domain_id;
     /** Partition to revoke access to */
-    private Partition partition;
+    private String partition_name;
 
     /**
      * Constructor for CommandPhysicalRevoke.
@@ -17,10 +17,10 @@ public class CommandPhysicalRevoke extends Command {
      * @param domain_id Domain to revoke access from.
      * @param partition Partition to revoke access to.
      */
-    public CommandPhysicalRevoke(Defaults d, int domain_id, Partition partition) {
+    public CommandPhysicalRevoke(Defaults d, int domain_id, String partition) {
         this.d = d;
         this.domain_id = domain_id;
-        this.partition = partition;
+        this.partition_name = partition;
     }
 
     /**
@@ -30,6 +30,13 @@ public class CommandPhysicalRevoke extends Command {
         Runtime r = Runtime.getRuntime();
         String output = null;
 
+        Partition partition = PartitionManager.IT.getPartition(partition_name);
+
+        if (partition == null) {
+            throw new CommandFailedException(
+                "Partition " + partition_name + " does not exist.");
+        }
+
         try {
             Process start_p;
             String start_cmdarray[] = new String[5];
index 2b7f150878e083925c8e15fd1854d02e45105fc3..8ac08832640ca0ec8d3e92104acc07d09f6d6dbc 100644 (file)
@@ -8,7 +8,7 @@ import java.io.IOException;
  */
 public class CommandVbdCreate extends Command {
     /** Virtual disk to map to. */
-    private VirtualDisk vd;
+    private String vd_key;
     /** Domain to create VBD for. */
     private int domain_id;
     /** VBD number to use. */
@@ -24,11 +24,11 @@ public class CommandVbdCreate extends Command {
      * @param mode Access mode to grant.
      */
     public CommandVbdCreate(
-        VirtualDisk vd,
+        String vd,
         int domain_id,
         int vbd_num,
         Mode mode) {
-        this.vd = vd;
+        this.vd_key = vd;
         this.domain_id = domain_id;
         this.vbd_num = vbd_num;
         this.mode = mode;
@@ -38,9 +38,13 @@ public class CommandVbdCreate extends Command {
      * @see org.xenoserver.control.Command#execute()
      */
     public String execute() throws CommandFailedException {
-        VirtualBlockDevice vbd;
+        VirtualDisk vd = VirtualDiskManager.IT.getVirtualDisk(vd_key);
+        if (vd == null) {
+            throw new CommandFailedException(
+                "No virtual disk with key " + vd_key);
+        }
 
-        vbd =
+        VirtualBlockDevice vbd =
             VirtualDiskManager.IT.createVirtualBlockDevice(
                 vd,
                 domain_id,
index b804ef2ac9b5e7336b49daed926c6a6257300386..2046525529322efe28646a6fc059fdf3443d7121 100644 (file)
@@ -8,7 +8,7 @@ import java.io.IOException;
  */
 public class CommandVbdCreatePhysical extends Command {
     /** Virtual disk to map to. */
-    private Partition partition;
+    private String partition_name;
     /** Domain to create VBD for. */
     private int domain_id;
     /** VBD number to use. */
@@ -24,11 +24,11 @@ public class CommandVbdCreatePhysical extends Command {
      * @param mode Access mode to grant.
      */
     public CommandVbdCreatePhysical(
-        Partition partition,
+        String partition,
         int domain_id,
         int vbd_num,
         Mode mode) {
-        this.partition = partition;
+        this.partition_name = partition;
         this.domain_id = domain_id;
         this.vbd_num = vbd_num;
         this.mode = mode;
@@ -38,14 +38,17 @@ public class CommandVbdCreatePhysical extends Command {
      * @see org.xenoserver.control.Command#execute()
      */
     public String execute() throws CommandFailedException {
-        VirtualDisk vd = new VirtualDisk("vbd:"+partition.getName());
-        vd.addPartition(partition,partition.getNumSects());
+        Partition partition = PartitionManager.IT.getPartition(partition_name);
+        if (partition == null) {
+            throw new CommandFailedException(
+                "No partition " + partition_name + " exists");
+        }
+
+        VirtualDisk vd = new VirtualDisk("vbd:" + partition.getName());
+        vd.addPartition(partition, partition.getNumSects());
 
-        VirtualBlockDevice vbd = new VirtualBlockDevice(
-                vd,
-                domain_id,
-                vbd_num,
-                mode);
+        VirtualBlockDevice vbd =
+            new VirtualBlockDevice(vd, domain_id, vbd_num, mode);
 
         String command = vd.dumpForXen(vbd);
 
@@ -55,7 +58,9 @@ public class CommandVbdCreatePhysical extends Command {
             fw.flush();
             fw.close();
         } catch (IOException e) {
-            throw new CommandFailedException("Could not write VBD details to /proc/xeno/dom0/vhd", e);
+            throw new CommandFailedException(
+                "Could not write VBD details to /proc/xeno/dom0/vhd",
+                e);
         }
 
         return "Created virtual block device "
index 4187b498902a30824d22087081603de8b8bff8f8..d8cdb247d0634f8c91ab054a0fcfb1749e6ce47c 100644 (file)
@@ -8,7 +8,7 @@ import java.util.Date;
 public class CommandVdCreate extends Command {
     /** Name of new disk. */
     private String name;
-    /** Size of new disk in sectors. */
+    /** Size of new disk in bytes. */
     private long size;
     /** Expiry date of new disk. */
     private Date expiry;
@@ -16,7 +16,7 @@ public class CommandVdCreate extends Command {
     /**
      * Constructor for CommandVdCreate.
      * @param name Name of new virtual disk.
-     * @param size Size in sectors.
+     * @param size Size in bytes.
      * @param expiry Expiry time, or null for never.
      */
     public CommandVdCreate(String name, long size, Date expiry) {
@@ -30,7 +30,10 @@ public class CommandVdCreate extends Command {
      */
     public String execute() throws CommandFailedException {
         VirtualDisk vd =
-            VirtualDiskManager.IT.createVirtualDisk(name, size, expiry);
+            VirtualDiskManager.IT.createVirtualDisk(
+                name,
+                size / Settings.SECTOR_SIZE,
+                expiry);
         if (vd == null) {
             throw new CommandFailedException("Not enough free space to create disk");
         }
index 5243cae566b00722c2f7ba6c116f88f570f96685..6fadde859c2ad58ff4ba669156b7b2e5c9010c6b 100644 (file)
@@ -19,6 +19,11 @@ public class CommandVdDelete extends Command {
      * @see org.xenoserver.control.Command#execute()
      */
     public String execute() throws CommandFailedException {
+        if (VirtualDiskManager.IT.getVirtualDisk(key) == null) {
+            throw new CommandFailedException(
+                "Virtual disk " + key + " does not exist");
+        }
+
         VirtualDiskManager.IT.deleteVirtualDisk(key);
         return "Deleted virtual disk " + key;
     }
index 7cfc918f29b4a63fd2dcdfac35f37d7667100e80..bc1e7e7c095f7b7a0d1f3a74895c3c02a075636c 100644 (file)
@@ -142,7 +142,7 @@ public class Partition {
      * @param other Other partition to compare to.
      * @return True if they are identical.
      */
-    public boolean identical(Partition other) {
+    boolean identical(Partition other) {
         return this.major == other.major
             && this.minor == other.minor
             && this.blocks == other.blocks
@@ -154,7 +154,7 @@ public class Partition {
     /**
      * @return An Extent covering this partiton.
      */
-    public Extent toExtent() {
+    Extent toExtent() {
         return new Extent(getDisk(),start_sect,nr_sects);
     }
 
@@ -162,7 +162,7 @@ public class Partition {
      * @param e Extent to compare this partition to.
      * @return True if this partition covers the same disk area as the given extent.
      */
-    public boolean matchesExtent(Extent e) {
+    boolean matchesExtent(Extent e) {
         return e.getDisk() == getDisk()
             && e.getOffset() == start_sect
             && e.getSize() == nr_sects;
index 8bacadbb4938ffd8357612867d1a85d9bf8c6297..f99085788dcf8348a11f601a34e4b411e1f1e33f 100644 (file)
@@ -227,7 +227,7 @@ public class VirtualDisk {
      * Reset the expiry time for this virtual disk.
      * @param expiry The new expiry time, or null for never.
      */
-    public void refreshExpiry(Date expiry) {
+    void refreshExpiry(Date expiry) {
         this.expiry = expiry;
     }
 }
index 7ac5e79e4dfae1a367b5566e2776f09f18444307..e872790dba71d3b967beaffa74212be002e3aceb 100644 (file)
@@ -45,7 +45,7 @@ public class VirtualDiskManager {
      * @param partition The partition to add.
      * @param chunkSize The chunk size to split the partition into, in sectors. 
      */
-    public void addPartition(Partition partition, long chunkSize) {
+    void addPartition(Partition partition, long chunkSize) {
         freeDisk.addPartition(partition, chunkSize);
     }
 
@@ -56,7 +56,7 @@ public class VirtualDiskManager {
      * @param expiry The expiry time, or null for never.
      * @return null if not enough space is available
      */
-    public VirtualDisk createVirtualDisk(String name, long size, Date expiry) {
+    VirtualDisk createVirtualDisk(String name, long size, Date expiry) {
         if (freeDisk.getSize() < size) {
             return null;
         }
@@ -83,7 +83,7 @@ public class VirtualDiskManager {
      * Delete a virtual disk, and put its extents back into the free pool.
      * @param key The key of the disk to delete.
      */
-    public void deleteVirtualDisk(String key) {
+    void deleteVirtualDisk(String key) {
         VirtualDisk vd;
 
         vd = (VirtualDisk) virtualDisks.get(key);
@@ -108,7 +108,7 @@ public class VirtualDiskManager {
      * @param mode The mode to create the device with.
      * @return The newly created virtual block device.
      */
-    public VirtualBlockDevice createVirtualBlockDevice(
+    VirtualBlockDevice createVirtualBlockDevice(
         VirtualDisk vd,
         int domain,
         int vbdNum,
@@ -126,7 +126,7 @@ public class VirtualDiskManager {
      * @param domain Domain owning the device.
      * @param vbdNum The vbd number within the domain.
      */
-    public void deleteVirtualBlockDevice(int domain, int vbdNum) {
+    void deleteVirtualBlockDevice(int domain, int vbdNum) {
         Object hash = hashVBD(domain, vbdNum);
         virtualBlockDevices.remove(hash);
     }
@@ -134,7 +134,7 @@ public class VirtualDiskManager {
     /**
      * Flush all virtual block devices.
      */
-    public void flushVirtualBlockDevices() {
+    void flushVirtualBlockDevices() {
         /* isn't automatic garbage collection wonderful? */
         virtualBlockDevices = new LinkedHashMap(100);
     }